package com.boge.flow;

import org.flowable.engine.ProcessEngine;
import org.flowable.engine.ProcessEngineConfiguration;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration;
import org.flowable.engine.repository.Deployment;
import org.junit.Test;

public class FlowableTest1 {

    public static final String JDBC_URL = "jdbc:mysql://localhost:3306/flowable-learn?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT&nullCatalogMeansCurrent=true";
    public static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
    public static final String JDBC_USER_NAME = "root";
    public static final String JDBC_PASSWORD = "1234";




    /**
     * 部署流程到数据库中
     * 在非Spring下的应用
     */
    @Test
    public void deployFlow(){
        //获取流程引擎对象
        ProcessEngineConfiguration processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration()
                .setJdbcUrl(JDBC_URL)
                .setJdbcDriver(JDBC_DRIVER)
                .setJdbcUsername(JDBC_USER_NAME)
                .setJdbcPassword(JDBC_PASSWORD)
                .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
        ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
        System.out.println("processEngine = " + processEngine);

        //部署流程
        RepositoryService repositoryService = processEngine.getRepositoryService();
        Deployment deploy = repositoryService.createDeployment()
                .addClasspathResource("process/01-base/FirstFlow.bpmn20.xml")
                .name("第1个流程图")
                .deploy();
        System.out.println("deploy.getId() = " + deploy.getId());
    }
}
